package com.rainner.admin.util.email;

import org.apache.commons.mail.EmailException;
import org.apache.commons.mail.SimpleEmail;

public class SendEmailUtil {
	/**
	 * 发送邮件帮助类
	 * @param readerName 读者姓名
	 * @param readerEmail 读者email
	 * @param sendMsg 发送的信息
	 * @throws EmailException
	 */
	public static void sendEmail(String readerName,String readerEmail,String sendMsg) throws EmailException{
		SimpleEmail email = new SimpleEmail();
		sendMsg = "亲爱的同学:你在中山图书馆借的书该还了啊!!!";
		//smtp host 
		email.setHostName("smtp.126.com");
		//登陆邮件服务器的用户名和密码
		email.setAuthentication("cqzstsg","cqzstsg123456");
		//接收人
		email.addTo(readerEmail, readerName);
		//发送人
		email.setFrom("cqzstsg@126.com", "中山图书馆管理处");
		
		email.setCharset("UTF-8");    
		//标题
		email.setSubject("欠费通知");
		//邮件内容
		email.setMsg(sendMsg);
		//发送
		email.send();
	}
}
